<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="s" uri="http://stripes.sourceforge.net/stripes.tld" %>

<s:layout-render name="/menu.jsp" nadpis="LectorLectures">
    <s:layout-component name="telo">
        <s:useActionBean beanclass="com.pa165.languageschoolpresentation.LectorActionBean" var="actionBean"/>   
        <f:message key="Lector"/>: <b>${actionBean.lectorDTO.name} </b><b>${actionBean.lectorDTO.surname} </b>
        <c:if test="${pageContext.request.isUserInRole('ROLE_ADMIN')}" >
            <br/>
            <f:message key="Total"/> = ${actionBean.lectures.size()}:
            <table class="table">
                <tr>
                    <th><f:message key="Number"/></th>
                    <th><f:message key="Id"/></th>
                    <th><f:message key="lecture.name"/></th>               
                    <th><f:message key="lecture.roomNumber"/></th>
                    <th><f:message key="lecture.startTime"/></th>
                    <th><f:message key="lecture.endTime"/></th>
                    <th><f:message key="Course"/></th>

                </tr>
                <c:forEach items="${actionBean.lectures}" var="lectureDTO" varStatus="loop">
                    <tr>
                        <td>${loop.index}</td>
                        <td>${lectureDTO.id}</td>                   
                        <td><c:out value="${lectureDTO.name}"/></td> 
                        <td><c:out value="${lectureDTO.roomNumber}"/></td>
                        <td><c:out value="${actionBean.sdfSource.format(lectureDTO.startTime)}"/></td>
                        <td><c:out value="${actionBean.sdfSource.format(lectureDTO.endTime)}"/></td>
                        <td><c:out value="${lectureDTO.course.name}"/></td>                    
                    </tr>
                </c:forEach>

            </table>        
            <s:form beanclass="com.pa165.languageschoolpresentation.LectorActionBean">
                <s:hidden name="lectorDTO.id"/>           
                <fieldset><legend><f:message key="lector.assignToLecture"/></legend>
                    <s:errors/>
                    <table>
                        <tr>
                            <th><s:label for="b4" name="Lecture"/><br/></th>
                            <td><s:select id="b4" name="lectureDTO.id">
                                    <s:options-collection collection="${actionBean.allLectures}" value="id" label="name" />  
                                </s:select></td>
                        </tr>
                    </table>                 
                    <s:submit name="enrollToLecture"><f:message key="lector.assign"/></s:submit>
                    </fieldset>
            </s:form>   
        </c:if>
        <br/><s:link beanclass="com.pa165.languageschoolpresentation.LectorActionBean" event="all"><f:message key="Back"/></s:link> 
    </s:layout-component>
</s:layout-render>